package com.lukk.handler;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.lukk.constant.Const;
import com.lukk.pojo.InternalWorker;

/**
 * 
 * LoginHandlerInterceptor 下午5:57:30 Copyright zhaocj Inc. All Rights reserved.
 * alldios@outlook.com
 *
 */
public class LoginHandlerInterceptor extends HandlerInterceptorAdapter {
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {
		HttpSession session = request.getSession();
		InternalWorker internalWorker = (InternalWorker) session.getAttribute(Const.SESSION_USER);
		if (internalWorker != null) {
			return true;
		} else {
			response.sendRedirect(request.getContextPath() + "/login.html");
			return false;
		}
	}
}
